package net.pm.core.service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.pm.common.service.GenericServicer;
import net.pm.common.toolkit.PMRetcodeGenerator;
import net.pm.common.toolkit.Pager;
import net.pm.core.entities.db.Orderinfo;

public interface OrderServicer extends GenericServicer<Orderinfo, Long>{
	
	/**创建新生产订单
	 * @param order
	 * @return
	 */
	Long createOrder(Orderinfo order);
	Long create_order_success = PMRetcodeGenerator.next();
	Long create_order_failed = PMRetcodeGenerator.next();
	
	/**
	 * 查看订单
	 * @param deptId
	 * @param pagesize
	 * @param pageno
	 * @return
	 */
	Pager<Orderinfo> findOrderPagerByOwner(Short statusKey,Date startdate,Date enddate,Integer pagesize,
			Integer pageno);
	
	/**
	 * 获取生产中的订单
	 * @param deptId
	 * @param userId
	 * @return
	 */
	List<Orderinfo> findOrdersOfStatusProduce(Integer deptId,Long userId);
	
	/**
	 * 订单状态,组别
	 */
	Map<Short, Short[]> statusesMap = new HashMap<Short, Short[]>() {
		private static final long serialVersionUID = 602287483829397526L;
		{
			// 默认显示订单状态为0等待生产,1生产中的订单
			put(Orderinfo.STATUS_DEFAULT_DISPLAY, new Short[] {
					Orderinfo.STATUS_WAIT, Orderinfo.STATUS_PRODUCE });
			// 状态为0等待生产
			put(Orderinfo.STATUS_WAIT, null);
			// 状态为1生产中的订单
			put(Orderinfo.STATUS_PRODUCE, null);
			// 状态为2生产完成
			put(Orderinfo.STATUS_FINISH, null);
			// 3生产失败
			put(Orderinfo.STATUS_FAILED, null);
			// 4生产取消
			put(Orderinfo.STATUS_CANCEL, null);
			// 显示全部
			put(Orderinfo.STATUS_ALL_DISPLAY, new Short[] {
					Orderinfo.STATUS_WAIT, Orderinfo.STATUS_PRODUCE,
					Orderinfo.STATUS_FINISH, Orderinfo.STATUS_FAILED,
					Orderinfo.STATUS_CANCEL, Orderinfo.STATUS_CANCEL });
		}
	};

	/**
	 * 投入生产
	 * @param orderId
	 */
	void intoProduce(Long orderId,Long userId);
	
	/**
	 * 取消订单
	 * @param orderId
	 */
	void cancelOrder(Long orderId);
	
	/**
	 * 删除订单
	 * @param orderId
	 */
	void removeOrder(Long orderId);
	
	
}
